package com.scau.XFourPOS.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@Embeddable
public class ProductStockPK implements Serializable {

	/**
	 * 【多个存货】对应 【一个货品】
	 */
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Product.class)
	private Product product;

	/**
	 * 码数
	 */
	@Column(name = "size", unique = true, nullable = false,length = 20)
	private String size;

	/**
	 * 无参构造函数
	 */
	public ProductStockPK(Product product, String size) {
		this.product=product;
		this.size=size;
	}

	/**
	 * 初始化全部属性的构造器
	 */
	public ProductStockPK() {

	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof ProductStockPK) {
			ProductStockPK pk = (ProductStockPK) obj;
			if (this.product.equals(pk.product) && this.size.equals(pk.size)) {
				return true;
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return super.hashCode();
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}
	
}
